// check_runtime_paths.js - 检查运行时路径
const path = require('path');
const fs = require('fs');

console.log('Current working directory:', process.cwd());
console.log('__dirname:', __dirname);

// 检查向量存储服务中的路径定义
const vectorStorePath = path.join(__dirname, '../backend/vector_store');
console.log('Vector store path from vectorStoreService:', vectorStorePath);
console.log('Vector store path exists:', fs.existsSync(vectorStorePath));

if (fs.existsSync(vectorStorePath)) {
    const files = fs.readdirSync(vectorStorePath);
    console.log('Files in vector store:', files);
}

// 检查实际的backend/vector_store路径
const actualVectorStorePath = path.join(__dirname, 'vector_store');
console.log('Actual vector store path:', actualVectorStorePath);
console.log('Actual vector store path exists:', fs.existsSync(actualVectorStorePath));

if (fs.existsSync(actualVectorStorePath)) {
    const files = fs.readdirSync(actualVectorStorePath);
    console.log('Files in actual vector store:', files);
    
    // 检查具体文件
    const indexPath = path.join(actualVectorStorePath, 'hnswlib.index');
    console.log('hnswlib.index path:', indexPath);
    console.log('hnswlib.index exists:', fs.existsSync(indexPath));
    
    if (fs.existsSync(indexPath)) {
        const stats = fs.statSync(indexPath);
        console.log('hnswlib.index size:', stats.size, 'bytes');
    }
}